<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('服务分类详细列表')" />
    <th:block th:include="include :: layout-latest-css" />
</head>
<body class="gray-bg">
    <div class="ui-layout-west">
        <div class="box box-main" style="height: 100%">
            <div class="box-header">
                <div class="box-title">
                    <i class="fa icon-grid"></i> 服务大类
                </div>
                <div class="box-tools pull-right">
                    <a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
                    <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
                </div>
            </div>
            <div class="col-sm-12 select-table table-bordered" style="height: 90%">
                <table id="bootstrap-table-first"></table>
            </div>
        </div>
    </div>
    <div class="ui-layout-center">
        <div class="container-div" style="height: 15%">
            <div class="row">
                <div class="btn-group-sm" id="toolbar2" role="group">
                    <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:serviceTypeDetail:add">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:serviceTypeDetail:edit">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:serviceTypeDetail:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>-->
                </div>
                <div class="col-sm-12 select-table table-bordered">
                    <div>
                        <form id="formId2">
                            <input type="hidden" id="serviceName" name="serviceName">
                            <div class="select-list">
                                <ul>
                                    <li>
                                        <label style="width: 120px;color: red">二级服务类型名称：</label>
                                        <input id="secondServiceName" type="text" name="secondServiceName" placeholder="请输入要查询的分类名称"/>
                                    </li>
                                    <li>
                                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.table.search('formId2','bootstrap-table-second')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                        <a class="btn btn-warning btn-rounded btn-sm" onclick="addSecond()"><i class="fa fa-plus"></i>&nbsp;新增二级服务类型</a>
                                    </li>
                                </ul>
                            </div>
                        </form>
                    </div>
                    <table id="bootstrap-table-second"></table>
                </div>
            </div>
        </div>
        <div class="container-div">
            <div class="row">
                <div class="btn-group-sm" id="toolbar3" role="group">
                    <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:serviceTypeDetail:add">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:serviceTypeDetail:edit">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:serviceTypeDetail:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>-->
                </div>
                <div class="col-sm-12 select-table table-bordered" >
                    <div>
                        <form id="formId">
                            <input type="hidden" id="serviceNameThird" name="serviceName">
                            <div class="select-list">
                                <ul>
                                    <li>
                                        <label style="width: 120px;color: red">三级服务类型名称：</label>
                                        <input id="thirdServiceName" type="text" name="thirdServiceName" placeholder="请输入要查询的名称"/>
                                    </li>
                                    <li>
                                        <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                        <a class="btn btn-success btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                        <a class="btn btn-success btn-rounded btn-sm" onclick="addThird()"><i class="fa fa-plus"></i>&nbsp;新增三级服务类型</a>
                                    </li>
                                </ul>
                            </div>
                        </form>
                    </div>
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:serviceTypeDetail:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:serviceTypeDetail:remove')}]];
        var prefix = ctx + "zsyh/serviceTypeDetail";

        $(function() {
            var panehHidden = false;
            if ($(this).width() < 769) {
                panehHidden = true;
            }
            $('body').layout({ initClosed: panehHidden, west__size: 185 });
            // 回到顶部绑定
            if ($.fn.toTop !== undefined) {
                var opt = {
                    win:$('.ui-layout-center'),
                    doc:$('.ui-layout-center')
                };
                $('#scroll-up').toTop(opt);
            }
            queryServiceTypeList();
            queryServiceTypeFirstList();
            queryServiceTypeSecondList();
        });

        function queryServiceTypeFirstList() {
            var options = {
                id: "bootstrap-table-first",
                /*toolbar: "toolbar1",*/
                url: prefix + "/list?serviceLevel=1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pagination: false,
                paginationLoop: true,
                modalName: "服务分类详细",
                columns: [
                    {
                        field: 'serviceName',
                        align: 'center',
                        title: '服务大类名称'
                    },
                    /*{
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }*/
                    ],onClickRow:function (row) {
                    $("#serviceName").val(row.serviceName);
                        $("#bootstrap-table-second").bootstrapTable('refresh', {query:{
                                serviceName: row.serviceName
                            }
                        });
                    $("#serviceNameThird").val(row.serviceName);
                        $("#bootstrap-table").bootstrapTable('refresh', {query:{
                                serviceName: row.serviceName
                            }
                        });
                   }

            };
            $.table.init(options);
        };

        function queryServiceTypeSecondList() {
            var options = {
                id: "bootstrap-table-second",
                toolbar: "toolbar2",
                url: prefix + "/listSecond",
                createUrl: prefix + "/addSecond/",
                updateUrl: prefix + "/editSecond/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pageSize: 4,
                modalName: "服务分类详细",
                queryParams: function (params) {
                    var temp ={};
                    if(params){
                        if (params.serviceName) {
                            temp.serviceName = params.serviceName
                        }
                    }
                    temp.serviceName = $("#serviceName").val();
                    temp.secondServiceName =$("#secondServiceName").val();
                    temp.serviceLevel ='2';
                    temp.pageSize =4;
                    temp.pageNum = params.offset / 4 + 1;
                    temp.pageOffset = params.offset;
                    return temp;
            },
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table-second').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table-second').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                    {
                        field: 'id',
                        title: 'id',
                        align: 'center',
                        visible: false
                    },
                    {
                        field: 'serviceName',
                        align: 'center',
                        title: '一级服务类型名称'
                    },{
                        field: 'secondServiceName',
                        align: 'center',
                        title: '二级服务类型名称'
                    },
                    /*{
                        field: 'parentId',
                        title: '服务类型父Id'
                    },*/
                    {
                        field: 'serviceImage',
                        align: 'center',
                        title: '服务类型图标',
                        formatter: function (value, row, index) {
                            return $.table.imageView(value);
                        }
                    },
                    {
                        field: 'serviceLevel',
                        align: 'center',
                        title: '服务类型等级'
                    },
                    /*{
                        field: 'serviceFixdraw',
                        align: 'center',
                        title: '固定抽成金额'
                    },*/
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        };

       function queryServiceTypeList() {
            var options = {
                id: "bootstrap-table",
                toolbar: "toolbar3",
                url: prefix + "/listThird/",
                createUrl: prefix + "/addThird/",
                updateUrl: prefix + "/editThird/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pageSize: 7,
                modalName: "服务分类详细",
                queryParams: function (params) {
                    var temp ={};
                    if(params){
                        if (params.serviceName) {
                            temp.serviceName = params.serviceName
                        }
                    }
                    temp.serviceName = $("#serviceNameThird").val();
                    temp.thirdServiceName =$("#thirdServiceName").val();
                    temp.serviceLevel ='3';
                    temp.pageSize =7;
                    temp.pageNum = params.offset / 7 + 1;
                    temp.pageOffset = params.offset;
                    return temp;
                },
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: 'id',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'serviceName',
                    align: 'center',
                    title: '一级服务类型名称'
                },
                    {
                        field: 'secondServiceName',
                        align: 'center',
                        title: '二级服务类型名称'
                    },
                    {
                        field: 'thirdServiceName',
                        align: 'center',
                        title: '三级服务类型名称'
                    },
                /*{
                    field: 'parentId',
                    title: '服务类型父Id'
                },*/
                {
                    field: 'serviceImage',
                    align: 'center',
                    title: '服务类型图标',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'serviceLevel',
                    align: 'center',
                    title: '服务类型等级'
                },
                {
                    field: 'serviceFixdraw',
                    align: 'center',
                    title: '固定抽成金额'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        };

       function addSecond() {
            $.modal.open("添加二级服务类型", prefix + "/addSecond");
        }

        function addThird() {
            $.modal.open("添加三级服务类型", prefix + "/addThird");
        }

        function dept() {
            var url = ctx + "zsyh/serviceTypeDetail";
            $.modal.openTab("服务大类管理", url);
        }

        $('#btnRefresh').click(function() {
            $('#bootstrap-table-first').bootstrapTable('refresh');
        });

    </script>
</body>
</html>